﻿#region Copyright & License
//
// Project: Quark Framework
// Project site: http://quark.codeplex.com
// See the copyright statement on the project site for more details.
//
// Licensed to the Apache Software Foundation (ASF) under one or more 
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership. 
// The ASF licenses this file to you under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with 
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Quark.Framework.Exceptions;

namespace Quark.Framework
{
    /// <summary>
    /// 访问配置数据的接口
    /// </summary>
    public interface IConfiguration
    {
        /// <summary>
        /// 获取当前配置实例的配置名称
        /// </summary>
        /// <query/>
        string ConfigurationKey
        {
            get;
        }

        /// <summary>
        /// 获取当前配置实例的配置值，该值可能是null
        /// </summary>
        /// <query/>
        object ConfigurationValue
        {
            get;
        }

        /// <summary>
        /// 获取当前配置实例的配置值
        /// </summary>
        /// <typeparam name="TValue">配置值类型</typeparam>
        /// <returns>配置值</returns>
        /// <exception cref="ConfigurationValueEmptyException">配置值为空值或不包含有效的配置值</exception>
        /// <query/>
        TValue GetTypedValue<TValue>();

        /// <summary>
        /// 在当前配置实例中获取匹配指定配置名称的子配置项
        /// </summary>
        /// <param name="name">配置子项的名称</param>
        /// <returns>返回对应该配置名称的配置子项，如果该配置名称不存在于配置子项集合，则返回null</returns>
        /// <exception cref="ArgumentNullException"><paramref name="name"/>为空值</exception>
        /// <remarks>
        /// 本方法仅查找当前配置实例下直接包含的配置子项集合，不会递归深度搜索配置子项下的子项集合
        /// </remarks>
        /// <threadsafety/>
        IConfiguration GetChild(string name);
    }
}
